<?php


namespace app\manager\controller;


use app\common\controller\Common;
use think\Db;

class Member extends Common
{
    public function lists(){
        if($this->request->isAjax()){
            $param = request()->param('key');
            $where = $param['key'];
            if (is_null(count($param['key']))) $where = [];
            $limit = $this->getPageSize();
            $member = \app\common\model\Member::where($where)->with('cards')->order('status','desc')->paginate($limit);
            if (count($member) == 0) return $this->errJson('暂无数据');
            return $this->listJson($member->items(), $member->total());
        }else{
            return view();
        }
    }

    public function setStatus()
    {////设置状态
        $memid = input('memid');
        if (is_null($memid)) return $this->errJson('参数错误');
        $Member = \app\common\model\Member::get($memid);
        $Member->status == 2 ? $Member->status = -1 : $Member->status = 2;
        $ret = $Member->save();
        if ($ret) return $this->okJson('ok');
        return $this->errJson('err');
    }

}